package com.cgsrp.cgsrp_baby.controller;

import com.cgsrp.cgsrp_baby.domain.Baby;
import com.cgsrp.cgsrp_baby.domain.vo.PicVo;
import com.cgsrp.cgsrp_baby.domain.vo.PicsVo;
import com.cgsrp.cgsrp_baby.service.BabyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("babyPic")
public class BabyPicController {
    @Autowired
    private BabyService babyService;

    @GetMapping("getPics")
    public PicsVo getPics(
            int userId,
            @RequestParam(defaultValue = "") String disc,
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "40") int pageSize
    ){
        pageNum=pageSize*(pageNum-1);
        return babyService.getPics(userId,disc,pageNum,pageSize);
    }
    @GetMapping("getBabies")
    public List<Baby> getBabies(int userId){
        return babyService.getBabies(userId);
    }

    @PostMapping("uploadVideo")
    public String uploadVideo(
            Integer babyId,
            String describe,
            MultipartFile fileCover,
            MultipartFile file,
            Integer userId
    ){
         return babyService.uploadVideo(babyId,describe,fileCover,file,userId);
    }

    @PostMapping("uploadPhotos")
    public String uploadPhotos(
            Integer babyId,
            String describe,
            MultipartFile[] photo,
            Integer userId
    ){
        return babyService.uploadPhotos(babyId,describe,photo,userId);
    }
}
